package cn.leftsite.netty.test.codec;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

/**
 * 扩展了MessageToByteEncoder
 * @author wangjinqiang
 * @date 2019-05-30
 */
public class CharToByteEncoder extends MessageToByteEncoder<Character> {
    @Override
    protected void encode(ChannelHandlerContext ctx, Character msg, ByteBuf out) throws Exception {
        // 将Character 解码为char，并将其写入到出站ByteBuf 中
        out.writeChar(msg);
    }
}
